package com.uniinnovate.lanjingling.service.impl;

import com.uniinnovate.lanjingling.dao.JobDao;
import com.uniinnovate.lanjingling.entity.JobEntity;
import com.uniinnovate.lanjingling.pojo.vo.JobVO;
import com.uniinnovate.lanjingling.service.JobService;
import com.uniinnovate.lanjingling.utils.R;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.uniinnovate.lanjingling.utils.PageUtils;
import com.uniinnovate.lanjingling.utils.Query;

import com.uniinnovate.lanjingling.dao.CompanyDao;
import com.uniinnovate.lanjingling.entity.CompanyEntity;
import com.uniinnovate.lanjingling.service.CompanyService;


@Service("companyService")
public class CompanyServiceImpl extends ServiceImpl<CompanyDao, CompanyEntity> implements CompanyService {

    @Autowired
    public JobService jobService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CompanyEntity> page = this.page(
                new Query<CompanyEntity>().getPage(params),
                new QueryWrapper<CompanyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R uploadJob(JobVO jobVO) {
        JobEntity job = new JobEntity();
        BeanUtils.copyProperties(jobVO,job);
        job.setIsAudit(0);
        boolean isSuccess = jobService.save(job);
        if(isSuccess){
            return R.ok("上传岗位成功");
        }else{
            return R.error("上传岗位失败");
        }
    }

    @Override
    public List<JobEntity> listJob(Long id) {
        return null;
    }

}